<?php
/* $Id$ */

require_once "ShockwaveFlashBase.class.php";

class ShockwaveFlashElements extends ShockwaveFlashBase {


	function ShockwaveFlashElements() {

		/* Superklasse aufrufen */
		$this->ShockwaveFlashBase( );

	}

	/**
         * text Element
         */

	function swf_set_new_text( $movie, $label, $xPos, $yPos, $fontName, $height, $color_arr, $string ) {

		$swf_class->registerLabel( $label, "text" );

		$text = new SWFText();
		$text->setFont( new SWFFont( $fontName ) );
		$text->setHeight( $height ); 
		$text->setColor(
			$color_arr[0],
			$color_arr[1],
			$color_arr[2]
		);
		$text->addString( $string );


		$text_item = $movie->add( $text );
		$text_item->moveTo( $xPos, $yPos );
		$text_item->setName( $label );

		return $text_item;

	}	

	/** 
	 * button Element
	 */

	function swf_make_easyButton( $movie, $label, $xPos, $yPos, $action ) {
		
		$upShape = new SWFShape(); 
			$upShape->setRightFill(0,0,255); 
			$upShape->drawLine(250,0); 
			$upShape->drawLine(0,60); 
			$upShape->drawLine(-250,0); 
			$upShape->drawLine(0,-60);
 
		$overShape = new SWFShape(); 
			$overShape->setRightFill(255,0,0); 
			$overShape->drawLine(250,0); 
			$overShape->drawLine(0,60); 
			$overShape->drawLine(-250,0); 
			$overShape->drawLine(0,-60); 

		$hitShape = new SWFShape(); 
			$hitShape->setRightFill(255,0,255); 
			$hitShape->drawLine(250,0); 
			$hitShape->drawLine(0,60); 
			$hitShape->drawLine(-250,0); 
			$hitShape->drawLine(0,-60); 

		$myFont=new SWFFont("FreeSerif.fdb"); 

		$myButton=new SWFButton(); 
			$myButton->setUp($upShape); 
			$myButton->setOver($overShape); 
			$myButton->setDown($hitShape); 
			$myButton->setHit($hitShape); 
			$myButton->setAction(new SWFAction($action) );


		$button_item = $movie->add( $myButton );
		$button_item->moveTo($xPos, $yPos);
		$button_item->setName( $label );


		return $button_item; 

	}

	/**
	 * picture Element
	 */

	function swf_set_new_picture( $movie, $label, $xPos, $yPos, $fileName) {


		$shape = new SWFShape();

		$b = new SWFBitmap( fopen( $fileName, "r" ) );


		echo "<p>".$b->getWidth()."x".$b->getHeight()."</p>";

		$shape_class = new SWFShape();
		$shape_class->setLine(1,0,0,0); 


		$shape_filled = $shape_class->addFill( $b, SWFFILL_TILED_BITMAP );

		$shape_class->setRightFill( $shape_filled );

		$pic_item = $movie->add( $shape_class );
		$pic_item->moveTo( $xPos, $yPos );

		return $pic_item;

	}

	/**
	 * picture_actionscript Element
	 */

	function swf_set_new_picture_as ( $movie, $fileName, $xPos, $yPos ) {

		$script = <<<EOF
createEmptyMovieClip('picxmms',10);
picxmms._x=$xPos;
picxmms._y=$yPos;
picxmms.loadMovie('$fileName');
EOF;

		$pic_item = $movie->add ( new SWFAction ( $script ) );

		//$pic_item->moveTo( $xPos, $yPos );

	}


}



?>